Page( {
  leftMove:0,
  leftrun:0,  
  rightMove:0,
  rightrun:0,
  data: {

    // 配置信息
    configData: [],
    //本页面需要显示的数据
    isInit: true,
    title: "",
    zhengTime: 0,
    fanTime: 0,
    zhengSound: "",
    fanSound: "",
    zhengDesc: "",
    fanDesc: "",
    actionSheetHidden: true,
    actionSheetItems: []    
  },
  onLoad: function( options ) {
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady: function() {
    // 页面渲染完成
  },
  onShow: function() {
    // 页面显示
    this.setData( { configData: wx.getStorageSync( 'configData' ) });   
    //初始化本页需要显示的数据
    if( this.data.isInit ) {   
      var configData = this.data.configData;
      this.setData( {
        isInit: false,
        title: configData[ 0 ].title,
        zhengTime: configData[ 0 ].maxTime,
        fanTime: configData[ 0 ].maxTime,
        zhengSound: configData[ 0 ].sound,
        fanSound: configData[ 0 ].sound,
        zhengDesc: configData[ 0 ].descZheng,
        fanDesc: configData[ 0 ].descFan,
        actionSheetItems: configData
      });
    } else {
      //切换页面时初始化显示的数据
      var configData = this.data.configData;
      var actionSheetItems = new Array();
      var first = true;      
      for( var i = 0;i < configData.length;i++ ) {
        if( !configData[ i ].hidden ) {
          if( first ) {
            this.setData( {
              title: configData[ i ].title,
              zhengTime: configData[ i ].maxTime,
              fanTime: configData[ i ].maxTime,
              zhengSound: configData[ i ].sound,
              fanSound: configData[ i ].sound,
              zhengDesc: configData[ i ].descZheng,
              fanDesc: configData[ i ].descFan
            });
            first = false;
          }
          actionSheetItems.push( configData[ i ] );
        }
      }
      this.setData( {
        actionSheetItems: actionSheetItems
      });
    }
  },
  onHide: function() {
    // 页面隐藏
  },
  onUnload: function() {
    // 页面关闭
  },
  stopLeftRun:function(){
      clearInterval(this.leftrun);
      this.leftrun = 0;
  },
  leftClick: function() {
    //var page
    //var zhengTime
    //var leftRun
    //var leftMove
    //var animation
    //stopLeftRun:function(){}
    

    //判断是否需要停止
    if(this.leftrun>0){
      this.stopLeftRun();
      return;
    }
    //创建动画
    var animation = wx.createAnimation( {
      transformOrigin: "50% 50%",
      duration: 1000,
      timingFunction: "linear",
      delay: 0
    })
    //动画执行
    animation.rotate( this.leftMove += 360  ).step();    
    this.setData( {
      animationData: animation.export()
    }); 
    var page = this;
    //动画持续执行
    this.leftrun = setInterval(function(){
      //判断是否还有剩余时间，否则停止
      if(page.data.zhengTime<=0){
        page.stopLeftRun();
        return;
      }
      animation.rotate( page.leftMove += 360  ).step();      
      page.setData( {
        animationData: animation.export(),
        zhengTime:page.data.zhengTime-1        
      });      
    },1000);  
      

  },
  selectJieduan: function() {
    this.setData( {
      actionSheetHidden: !this.data.actionSheetHidden
    });
  },
  actionSheetChange: function() {
    this.setData( {
      actionSheetHidden: !this.data.actionSheetHidden
    });
  },
  bindItemTap: function( e ) {
    var index = e.target.dataset.name
    var item = this.data.actionSheetItems;
    this.setData( {
      actionSheetHidden: !this.data.actionSheetHidden,
      title: item[ index ].title,
      zhengTime: item[ index ].maxTime,
      fanTime: item[ index ].maxTime,
      zhengSound: item[ index ].sound,
      fanSound: item[ index ].sound,
      zhengDesc: item[ index ].descZheng,
      fanDesc: item[ index ].descFan
    });
  }

})